package cn.edu.gduf.luowowo.website.advice;

import cn.edu.gduf.luowowo.common.exception.LogicException;
import cn.edu.gduf.luowowo.common.util.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionControllerAdvice {

    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public Object HandleLogicException(LogicException e){
        e.printStackTrace();
        return new AjaxResult(false, e.getMessage());
    }

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Object HandleRuntimeException(Exception e){
        e.printStackTrace();
        return new AjaxResult(false, "系统繁忙，请稍后重试");
    }
}
